/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ipti.br.tag.bean.dataManipulation;

import org.ipti.br.tag.entity.UnitySchedule;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.primefaces.model.ScheduleEvent;
import org.primefaces.model.ScheduleModel;

/**
 *
 * @author luancorumba
 */
public class UnityScheduleModel implements ScheduleModel,Serializable{

    private Map<String,ScheduleEvent> events;

    public UnityScheduleModel() {
        this.events = new HashMap<String, ScheduleEvent>();
    }
    
    @Override
    public void addEvent(ScheduleEvent se) {
        events.put(se.getId(), se);
    }

    @Override
    public boolean deleteEvent(ScheduleEvent se) {
        return events.remove(se.getId()).equals(se);
    }

    @Override
    public List<ScheduleEvent> getEvents() {
        return new ArrayList<ScheduleEvent>(events.values());
    }

    @Override
    public ScheduleEvent getEvent(String string) {
        return events.get(string);
    }

    @Override
    public void updateEvent(ScheduleEvent se) {
        events.put(((UnitySchedule) se.getData()).getId().toString(), se);
    }

    @Override
    public int getEventCount() {
        return events.size();
    }

    @Override
    public void clear() {
        events.clear();
    }
}
